package cn.hnu.qq.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;

import cn.hnu.qq.entity.message.Message;
import cn.hnu.qq.global.MessageType;

@Entity
public class TaskEvent extends Message implements Serializable{

	/**
	 *   用户或者系统待处理事件
	 */
	private static final long serialVersionUID = 1L;

	private MessageType messageType;
	
	private Integer id;
	
	private User maker;
	
	private User dealer;
	
	private Date time;
	
	private String source;//留言需要的 加入群组的额外信息

	public TaskEvent(){};
	
	public TaskEvent(MessageType type){
		setMessageType(type);
	}
	@Id @GeneratedValue(strategy = GenerationType.AUTO)
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	@Column(nullable=false)
	public Date getTime() {
		return time;
	}

	public void setTime(Date time) {
		this.time = time;
	}

	@ManyToOne(cascade={CascadeType.MERGE})
	public User getMaker() {
		return maker;
	}

	public void setMaker(User maker) {
		this.maker = maker;
	}
	@ManyToOne(cascade={CascadeType.MERGE})
	public User getDealer() {
		return dealer;
	}

	public void setDealer(User dealer) {
		this.dealer = dealer;
	}
	@Column(nullable=true)
	public String getSource() {
		return source;
	}

	public void setSource(String source) {
		this.source = source;
	}

	@Override
	public String toString() {
		return "TaskEvent [id=" + id + ", maker=" + maker + ", dealer="
				+ dealer + ", time=" + time + ", source=" + source + "]";
	}

	@Enumerated(EnumType.STRING)
	@Column(nullable=false)
	public MessageType getMessageType() {
		return messageType;
	}

	public void setMessageType(MessageType type) {
		this.messageType = type;
	}

	
}
